//
//  CHPhotoImgView.m
//  CarFile
//
//  Created by 陈浩 on 2017/8/6.
//  Copyright © 2017年 陈浩. All rights reserved.
//

#import "CHPhotoImgView.h"

@interface CHPhotoImgView()
@property(strong,nonatomic)UIImageView *gif;

@end

@implementation CHPhotoImgView

-(instancetype)initWithFrame:(CGRect)frame{
    if (self = [super  initWithFrame:frame]) {
        
        //设置图片模式
        self.clipsToBounds = YES;
        
        // 图片按比例缩放，填满整个UIImageView
        self.contentMode =  UIViewContentModeScaleAspectFill;
        
        //添加gif图标
        UIImageView *gif = [[UIImageView alloc] init];
        gif.image = [UIImage imageNamed:@"timeline_image_gif"];
        [self addSubview:gif];
        self.gif = gif;
    }
    
    return self;
}
/*
 // Only override drawRect: if you perform custom drawing.
 // An empty implementation adversely affects performance during animation.
 - (void)drawRect:(CGRect)rect {
 // Drawing code
 }
 */
//
//-(void)setPhoto:(CZPhoto *)photo{
//    _photo = photo;
//    
//    // 下载图片
//    [self sd_setImageWithURL:[NSURL URLWithString:photo.thumbnail_pic]];
//    
//    // 隐藏gif图标
//    //    CZLog(@"%@",photo.thumbnail_pic);
//    self.gif.hidden = ![photo.thumbnail_pic hasSuffix:@".gif"];
//    
//}


-(void)layoutSubviews{
    
    [super layoutSubviews];
    
    // 设置gif 的frm
    CGSize gifSize = self.gif.image.size;
    
    CGFloat gifX = self.w - gifSize.width;
    CGFloat gifY = self.h - gifSize.height;
    self.gif.frame = (CGRect){gifX,gifY,gifSize};
    
    
}

@end
